home *** CD-ROM | disk | FTP | other *** search
/ United Public Domain Gold 2 / United Public Domain Gold 2.iso / utilities / pu295.dms / pu295.adf / Logging / CQWWLog / CQWWLOG.BAS < prev    next >
BASIC Source File  |  1988-12-18  |  18KB  |  532 lines

  1. ' CQWWLOG.BAS version 1.2
  2. ' Copyright © 1986,1987 by Clarke Greene K1JX (NOT FOR COMMERCIAL USE)
  3. ' Amiga Version by John Gager K7KB 
  4. '
  5. ' This Microsoft (tm) BASIC program will build a complete log package
  6. ' for the CQ Worldwide DX Contest.
  7. '
  8. ' The file containing the log entries must be an ASCII file in the
  9. ' following format:
  10. '             (each band requires a separate log entry file)
  11. '
  12. ' TIME         CALLSIGN            RCV'D REPORT  (each log entry must
  13. '                                                 be followed by a
  14. '                                                 carriage return)
  15. '
  16. ' At least one space must be between each field of each log entry. Only
  17. ' a changed digit in the TIME field must be present; for example, If
  18. ' the contest begins at 1800Z and the first contact is made at 1802Z 
  19. ' and the second contact is made at 1805Z, then only 5 need be entered
  20. ' in the TIME field. IF the third contact is made at 1812 Z, then 12 
  21. ' should be entered in the TIME field. IF the next contact is made at 
  22. ' 1812 Z, then no number need be entered in the TIME field (however, be
  23. ' sure to enter a space to indicate separation between fields)!
  24. '
  25. ' These files will be produced:
  26. '
  27. ' <filename>.LOG - this is a complete log ready for printing
  28. ' <filename>.DUP - this is a sorted duplicate listing ready for printing
  29. ' <filename>.SUM - this is a summary sheet ready for printing
  30. '
  31. '
  32. ' Depending on the version of BASIC for your particular machine, the
  33. ' CLS (Clear Screen) command must be changed.  Consult your own 
  34. ' computer's BASIC documentation for more information.
  35. '
  36. '
  37. ' If compiling (a VERY good idea for several orders of magnitude
  38. ' improvement in speed), use O and E switches 
  39. '
  40. ' This program also uses a prefix library file (DXPREFIX.LIB), which
  41. ' MUST be on the same disc (and in the same subdirectory) as this
  42. ' program.
  43. '
  44. '  Define arrays and variables
  45. '
  46. CLEAR ,80000& : DEFINT a-Z : OPTION BASE 1
  47. DIM ENTRY$(1500), MULT$(175), PFX$(1000), CTRY$(1000), CNT$(1000), WIERDPFX$(50), WIERDCTRY$(50), WIERDCNT$(50), AMBCTRY$(10)
  48. DIM Q(175), ZONE(40)
  49. BLANK$=" " : BL$="" : SLANT$="/" : TRUE=-1
  50. DUPE1$="  - Duplica" : DUPE2$="te QSO -"
  51. '
  52. '  Define format strings for printouts
  53. '
  54. LOGFORM$=" \      \  \  \   \           \   \   \   \   \   \         \\           \  #"
  55. DUPFORM$="     \          \   \          \   \          \   \          \   \          \"
  56. SUMFORM$="     \          \   \          \   \          \   \          \   \          \"
  57. FOOTFORM$=" ##         ##          ##        ###"
  58. '
  59. CLS
  60. COLOR 3 : PRINT TAB(26) "CQWW DX Contest Log Processor" : COLOR 1
  61. PRINT : PRINT
  62. '
  63. '  Read Prefix table file
  64. '
  65. PRINT TAB(5)  "Reading prefix library...";
  66. I=0 ' initialize array subscript
  67. OPEN ":DXPREFIX.LIB" FOR INPUT AS #1
  68. WHILE NOT EOF(1)
  69.   I=I+1
  70.   INPUT #1, PFX$(I), DUMMY$, CTRY$(I), CNT$(I) ' DUMMT$ is a dummy
  71.                                                ' variable FOR DATA not
  72.                                                ' used
  73. WEND
  74. CLOSE
  75. TABLESIZE=I ' prefix table length
  76. COLOR 3 : PRINT "Done" : COLOR 1
  77. '
  78. '  Get user input
  79. '
  80. PRINT : PRINT TAB(5) "What is the station callsign?  ";
  81. INPUT "", MYCALL$ : MYCALL$=UCASE$(MYCALL$)
  82. THISENTRY$=MYCALL$ : IF INSTR(THISENTRY$,SLANT$)>0 THEN GOSUB GetPortPrefix ELSE THISPFX$=LEFT$(THISENTRY$,4)
  83. GOSUB SearchPrefix : IF NOT INLIST THEN GOSUB SearchWierd
  84. MYCTRY$=THISCTRY$ : MYCNT$=THISCNT$ : IF MYCNT$="NA" THEN MYCNTPTS=2 ELSE MYCNTPTS=1
  85.  
  86. ZoneEntry:
  87.  
  88. PRINT : PRINT TAB(5) "What is the station's WAZ zone?  ";
  89. INPUT "", MYZONE$
  90. IF VAL(MYZONE$)<1 OR VAL(MYZONE$)>40 THEN PRINT CHR$(7);: GOTO ZoneEntry
  91. IF VAL(MYZONE$)<10 AND LEN(MYZONE$)=1 THEN MYZONE$="0"+MYZONE$
  92. PRINT : PRINT TAB(5) "What is the beginning date of the contest ";
  93. COLOR 3 : PRINT"<DD/MM/YY>";:COLOR 1:PRINT"?  ";
  94. INPUT "", STARTDATE$
  95. MARK=INSTR(STARTDATE$,"/") : IF MARK=0 THEN MARK=INSTR(STARTDATE$,"-")
  96. STARTDAY=VAL(LEFT$(STARTDATE$,MARK-1))
  97. STARTDATE$=RIGHT$(STARTDATE$,LEN(STARTDATE$)-MARK)
  98. MARK=INSTR(STARTDATE$,"/") : IF MARK=0 THEN MARK=INSTR(STARTDATE$,"-")
  99. MON=VAL(LEFT$(STARTDATE$,MARK-1))
  100. IF MON=10 THEN MON$=" Oct.  " : RST$="59" ELSE MON$=" Nov.  " : RST$="599"
  101. SENT$=RST$+MYZONE$
  102. yr$=RIGHT$(STARTDATE$,LEN(STARTDATE$)-MARK)
  103. PRINT : PRINT TAB(5) "What is the GMT starting time for the contest?  ";
  104. INPUT "", STARTGMT$
  105. PRINT : PRINT TAB(5) "What file is the log extract located in?  ";
  106. INPUT "", INFILE$ : GOSUB CheckForFile ' check to see if file is valid
  107. IF INSTR(INFILE$,".")<>0 THEN OUTFILE$=LEFT$(INFILE$,INSTR(INFILE$,".")-1) ELSE OUTFILE$=INFILE$
  108. PRINT : PRINT TAB(5) "What frequency band is the log extract for?  ";
  109. INPUT "", BAND$
  110. '
  111. '  Build log file
  112. '
  113. CLS
  114. PRINT : PRINT TAB(5) "Duping and counting...";
  115. '
  116. '  Clear arrays
  117. '
  118. FOR I=1 TO 1500
  119.   ENTRY$(I)=BL$
  120. NEXT I
  121. FOR I=1 TO 175
  122.   MULT$(I)=BL$
  123.   Q(I)=1
  124. NEXT I
  125. FOR I=1 TO 40
  126.   ZONE(I)=0
  127. NEXT I
  128. '
  129. '  Initialize variables
  130. '
  131. RAWTOTAL=0 : QSOS=0 : DUPES=0 : CTRYNR=0 : ZONENR=0 : TOTPOINTS=0
  132. PGQSOS=0 : PGZONES=0 : PGCTRY=0 : PGPTS=0
  133. DAY=STARTDAY : PREVIOUSGMT$=STARTGMT$
  134. '
  135. '  Open input file and output .LOG file
  136. '
  137. OPEN INFILE$ FOR INPUT AS #1 LEN=5000
  138. OPEN OUTFILE$+".LOG" FOR OUTPUT AS #2 LEN=5000
  139. '
  140. '  Input data, process, and enter into output file
  141. '
  142. WHILE NOT EOF(1)
  143.   LINE INPUT #1, THISENTRY$ ' read entire line from disc file
  144.   IF LEN(THISENTRY$)=0 THEN SkipEntry
  145.   WHILE ASC(RIGHT$(THISENTRY$,1))<48 AND LEN(THISENTRY$)>0
  146.     THISENTRY$=LEFT$(THISENTRY$,LEN(THISENTRY$)-1) ' strip off trailing
  147.                                                    ' spaces, etc.
  148.   WEND
  149.   IF LEN(THISENTRY$)>0 THEN RAWTOTAL=RAWTOTAL+1 ELSE GOTO SkipEntry
  150.   '
  151.   '  Separate received report from THISENTRY$
  152.   '
  153.   RCVD$=BL$ ' initialize RCVD$ to be null string
  154.   WHILE ASC(RIGHT$(THISENTRY$,1))>=48
  155.     RCVD$=RIGHT$(THISENTRY$,1)+RCVD$
  156.     THISENTRY$=LEFT$(THISENTRY$,LEN(THISENTRY$)-1) ' parse last character
  157.                                                    ' of string
  158.   WEND
  159.   IF LEN(RCVD$)<=2 THEN RCVD$=RST$+RCVD$ ' if no RST was typed, append
  160.                                          ' standard report
  161.   IF LEN(RCVD$)<(LEN(RST$)+2) THEN RCVD$=LEFT$(RCVD$,LEN(RST$))+"0"+RIGHT$(RCVD$,1)
  162.   WHILE ASC(RIGHT$(THISENTRY$,1))<48
  163.     THISENTRY$=LEFT$(THISENTRY$,LEN(THISENTRY$)-1) ' strip off trailing
  164.                                                    ' spaces, etc.
  165.   WEND
  166.   '
  167.   '  Separate GMT from THISENTRY$
  168.   '
  169.   WHILE ASC(LEFT$(THISENTRY$,1))<48
  170.     THISENTRY$=RIGHT$(THISENTRY$,LEN(THISENTRY$)-1) ' strip off leading
  171.                                                     ' spaces
  172.   WEND
  173.   IF INSTR(THISENTRY$,BLANK$)<>0 THEN GMT$=LEFT$(THISENTRY$,INSTR(THISENTRY$,BLANK$)-1) ELSE GMT$=BL$
  174.   THISENTRY$=RIGHT$(THISENTRY$,(LEN(THISENTRY$)-LEN(GMT$)))
  175.   WHILE LEFT$(THISENTRY$,1)=BLANK$
  176.     THISENTRY$=RIGHT$(THISENTRY$,LEN(THISENTRY$)-1) ' strip off leading 
  177.                                                     ' spaces
  178.   WEND
  179.   '
  180.   '  Fill in missing time data 
  181.   '
  182.   GMT$=LEFT$(PREVIOUSGMT$,(4-LEN(GMT$)))+GMT$
  183.   THEDATE$=BL$ : IF GMT$<PREVIOUSGMT$ THEN DAY=DAY+1 : THEDATE$=STR$(DAY)+MON$
  184.  
  185.   THISENTRY$=UCASE$(THISENTRY$)
  186.   '
  187.   '  Check for dupes
  188.   '
  189.   DUPE.QSO=NOT TRUE : points=3
  190.   FOR J=1 TO QSOS
  191.     IF LEN(ENTRY$(J))<>LEN(THISENTRY$) GOTO NextDupe
  192.     IF ENTRY$(J)=THISENTRY$ THEN NEWZONE$=DUPE1$ : NEWCTRY$=DUPE2$ : DUPES=DUPES+1 : points=0 : DUPE.QSO=TRUE : J=QSOS
  193.   NextDupe: NEXT J
  194.   IF DUPE.QSO GOTO WriteEntry ' skip over prefix search if this entry is a dupe
  195.   QSOS=QSOS+1 : ENTRY$(QSOS)=THISENTRY$
  196.   '
  197.   '  Determine zone and search zone table for new multiplier
  198.   '
  199.   NEWZONE$=BL$
  200.   THISZONE$=RIGHT$(RCVD$,2)
  201.   J=VAL(THISZONE$) : IF J<1 OR J>40 THEN GOSUB BadZone
  202.   IF ZONE(J)=0 THEN ZONENR=ZONENR+1 : NEWZONE$="Zone #"+STR$(ZONENR) : PGZONES=PGZONES+1
  203.   ZONE(J)=ZONE(J)+1
  204.   '
  205.   '  Determine prefix and search prefix library for contact country and continent
  206.   '
  207.   IF INSTR(THISENTRY$,SLANT$)>0 THEN GOSUB GetPortPrefix ELSE THISPFX$=LEFT$(THISENTRY$,4)
  208.   GOSUB SearchPrefix
  209.   IF NOT INLIST THEN
  210.     GOSUB SearchWierd
  211.     CLS:PRINT:PRINT TAB(5) "Back to duping and counting...";
  212.   END IF
  213.   IF ASC(THISCTRY$)<48 THEN GOSUB ResolvePrefix ' resolve ambiguous
  214.                                                 ' prefix
  215.   '
  216.   '  Search multiplier table for new country
  217.   '
  218.   NEWMULT=TRUE : NEWCTRY$=BL$
  219.   FOR J=1 TO CTRYNR
  220.     IF MULT$(J)=THISCTRY$ THEN Q(J)=Q(J)+1 : NEWMULT=NOT TRUE : J=CTRYNR
  221.   NEXT J
  222.   IF NEWMULT THEN CTRYNR=CTRYNR+1 : MULT$(CTRYNR)=THISCTRY$ : NEWCTRY$=THISCTRY$+" #"+STR$(CTRYNR) : PGCTRY=PGCTRY+1
  223.   '
  224.   '  Determine point value for QSO
  225.   '
  226.   IF THISCTRY$=MYCTRY$ THEN points=0 : GOTO UpdatePage
  227.                                                  ' contacts in your own
  228.                                                  ' country are worth 0
  229.                                                  ' points
  230.   IF THISCNT$=MYCNT$ THEN points=MYCNTPTS
  231.   '
  232.   '  Update page totals
  233.   '
  234.   UpdatePage:
  235.   
  236.   PGQSOS=PGQSOS+1 : PGPTS=PGPTS+points
  237.   TOTPOINTS=TOTPOINTS+points
  238.   '
  239.   '  Write entry to file
  240.   '
  241.   WriteEntry:
  242.     
  243.   IF (RAWTOTAL-1) MOD 50=0 THEN GOSUB PrintHeader ' print header if this
  244.                                                   ' is the beginning of
  245.                                                   ' a page
  246.   PRINT #2, USING LOGFORM$; THEDATE$; GMT$; THISENTRY$; SENT$; RCVD$; NEWZONE$; NEWCTRY$; points
  247.   IF RAWTOTAL MOD 50=0 THEN GOSUB PrintFooter ' print footer if this is the
  248.                                               ' END of a page
  249.   PREVIOUSGMT$=GMT$ : GMT$=BL$
  250.  
  251. SkipEntry:
  252. WEND
  253. GOSUB PrintFooter
  254. IF RAWTOTAL MOD 50<>0 THEN PRINT#2, CHR$(12) ' if form feed hasn't been
  255.                                              ' printed, PRINT one now
  256. CLOSE
  257. COLOR 3 : PRINT "Done" : COLOR 1
  258. '
  259. '  Build dupe sheet
  260. '
  261. PRINT : PRINT TAB(5) "Preparing dupe sheet...";
  262. '
  263. '  Sort callsigns for dupe sheet
  264. '
  265. M=QSOS\2
  266. WHILE M>0
  267.   FOR I=M+1 TO QSOS
  268.     J=I-M
  269.       WHILE J>0
  270.         IF ENTRY$(J)>ENTRY$(J+M) THEN SWAP ENTRY$(J),ENTRY$(J+M) : J=J-M ELSE J=0
  271.       WEND
  272.   NEXT I
  273.   M=M\2
  274. WEND
  275. '
  276. '  Enter dupe sheet into file
  277. '
  278. OPEN OUTFILE$+".DUP" FOR OUTPUT AS #1
  279. IF QSOS MOD 250=0 THEN LASTPAGE=QSOS\250 ELSE LASTPAGE=QSOS\250+1
  280. FOR page=1 TO LASTPAGE
  281.   PRINT #1, SPC(20-(LEN(MYCALL$)+LEN(BAND$))/2); MYCALL$; " -- Dupe Sheet for ";
  282.   PRINT #1, BAND$; " MHz Band -- Page"; STR$(page)
  283.   PRINT #1, BL$ : PRINT #1, BL$
  284.   FOR ROW=1 TO 50
  285.     E=(page-1)*250+ROW
  286.     PRINT #1, USING DUPFORM$; ENTRY$(E); ENTRY$(E+50); ENTRY$(E+100); ENTRY$(E+150); ENTRY$(E+200)
  287.   NEXT ROW
  288.   PRINT #1, CHR$(12) ' go to next page
  289. NEXT page
  290. CLOSE
  291. COLOR 3 : PRINT "Done" : COLOR 1
  292. '
  293. '  Build summary listing
  294. '
  295. PRINT : PRINT TAB(5) "Preparing summary sheet...";
  296. '
  297. '  Sort countries for summary sheet
  298. '
  299. M=CTRYNR\2
  300. WHILE M>0
  301.   FOR I=M+1 TO CTRYNR
  302.     J=I-M
  303.     WHILE J>0
  304.       IF MULT$(J)>MULT$(J+M) THEN SWAP MULT$(J),MULT$(J+M) : SWAP Q(J),Q(J+M) : J=J-M ELSE J=0
  305.     WEND
  306.   NEXT I
  307.   M=M\2
  308. WEND
  309. '
  310. '  Append number of qsos per country onto country prefixes
  311. '
  312. FOR I=1 TO CTRYNR
  313.   MULT$(I)=MULT$(I)+SPACE$(6-LEN(MULT$(I)))+" -"+STR$(Q(I))
  314. NEXT I
  315. '
  316. '  Enter country listing into file
  317. OPEN OUTFILE$+".SUM" FOR OUTPUT AS #1
  318. PRINT #1, SPC(12-(LEN(MYCALL$)+LEN(BAND$))/2); MYCALL$; " -- Summary Sheet for "; BAND$;
  319. PRINT #1, " MHz Band - "; yr$; " CQWW DX Contest" 
  320. PRINT #1, BL$
  321. PRINT #1, TAB(15); "Country Listing and number of contacts per Country"
  322. PRINT #1, BL$ : PRINT #1, BL$
  323. IF CTRYNR MOD 5=0 THEN LASTROW=CTRYNR\5 ELSE LASTROW=CTRYNR\5+1
  324. FOR ROW=1 TO LASTROW
  325.   PRINT #1, USING SUMFORM$; MULT$(ROW); MULT$(ROW+LASTROW); MULT$(ROW+LASTROW*2); MULT$(ROW+LASTROW*3); MULT$(ROW+LASTROW*4)
  326. NEXT ROW
  327. '
  328. '  Build listing of zones worked and contacts per zone
  329. '
  330. J=0
  331. FOR I=1 TO 40
  332.   IF ZONE(I)>0 THEN J=J+1 : MULT$(J)="Zone"+STR$(I)+" -"+STR$(ZONE(I))
  333. NEXT I ' put zone count into array
  334. FOR I=J TO 40
  335.   MULT$(I)=BL$
  336. NEXT I ' blank out remainder of array
  337. '
  338. '  Enter zone listing
  339. '
  340. PRINT #1, BL$ 
  341. PRINT #1, TAB(18); "Zone Listing and number of contacts per Zone"
  342. PRINT #1, BL$ 
  343. IF ZONENR MOD 5=0 THEN LASTROW=ZONENR\5 ELSE LASTROW=ZONENR\5+1
  344. FOR ROW=1 TO LASTROW
  345.   PRINT #1, USING SUMFORM$; MULT$(ROW); MULT$(ROW+LASTROW); MULT$(ROW+LASTROW*2); MULT$(ROW+LASTROW*3); MULT$(ROW+LASTROW*4)
  346. NEXT ROW
  347. '
  348. '  Enter summary into file
  349. '
  350. PRINT #1, BL$ : PRINT #1, BL$
  351. PRINT #1, "     Total Valid QSOs - "; STR$(QSOS); "       Dupes - "; STR$(DUPES)
  352. PRINT #1, "     QSO points - "; STR$(TOTPOINTS)
  353. PRINT #1, "     Zones - "; STR$(ZONENR)
  354. PRINT #1, "     Countries - "; STR$(CTRYNR)
  355. CLOSE
  356. COLOR 3 : PRINT "Done" : COLOR 1
  357. '
  358. '  Print results
  359. '
  360. CLS : PRINT CHR$(7)
  361. PRINT : PRINT TAB(5) "Results for the "; BAND$; " MHz band":PRINT 
  362. PRINT TAB(8) "Valid QSOs:";:COLOR 3:PRINT USING"       ####";QSOS:COLOR 1
  363. PRINT TAB(8) "Duplicate QSOs:";:COLOR 3:PRINT USING"     ##";DUPES:COLOR 1
  364. PRINT TAB(8) "QSO points:";:COLOR 3:PRINT USING"    ######,";TOTPOINTS:COLOR 1
  365. PRINT TAB(8) "Zones:";:COLOR 3:PRINT USING"              ##";ZONENR:COLOR 1
  366. PRINT TAB(8) "Countries:";:COLOR 3:PRINT USING"         ###";CTRYNR:COLOR 1
  367. PRINT : PRINT : PRINT 
  368. PRINT TAB(5) "Type ";:COLOR 3:PRINT"C";:COLOR 1
  369. PRINT" to continue with another band,"
  370. PRINT TAB(5) "or any other key to Exit";
  371. ANS$=INPUT$(1)
  372. IF UCASE$(ANS$)="C" THEN CLS : GOTO GetLog ELSE CLS : END
  373. '
  374. '  Subroutine to trap missing file
  375. '
  376. CheckForFile:
  377.  
  378. ON ERROR GOTO Nofile
  379. OPEN INFILE$ FOR INPUT AS #1 ' try opening file
  380. ON ERROR GOTO 0
  381. CLOSE
  382. RETURN
  383.  
  384. Nofile:
  385.  
  386. PRINT CHR$(7) : PRINT TAB(4) "That file does not exist - type X to Exit or any other key to continue ";
  387. ANS$=INPUT$(1) : IF ANS$="X" OR ANS$="x" THEN CLS : SYSTEM
  388. PRINT 
  389. RESUME GetLog
  390. '
  391. '  Subroutine to clear up impossible zone number
  392. '
  393. BadZone:
  394. CLS
  395. PRINT CHR$(7) : PRINT
  396. PRINT TAB(5) "The zone for ";:COLOR 3:PRINT THISENTRY$;
  397. PRINT" ["; THISZONE$; "]";:COLOR 1:PRINT" must be incorrect."
  398. PRINT : PRINT TAB(8) "What is the correct zone number?  "; 
  399. INPUT "", THISZONE$ : J=VAL(THISZONE$)
  400. IF J<1 OR J>40 GOTO BadZone
  401. CLS:PRINT : PRINT TAB(5) "Back to duping and counting...";
  402. RETURN
  403. '
  404. '  Subroutine to determine prefix from portable designator
  405. '
  406. GetPortPrefix:
  407.  
  408. MARK=INSTR(THISENTRY$,SLANT$)
  409. IF MARK>3 THEN THISPFX$=RIGHT$(THISENTRY$,LEN(THISENTRY$)-MARK) ELSE THISPFX$=LEFT$(THISENTRY$,MARK-1)
  410. IF LEN(THISPFX$)>1 GOTO ReturnPfx ' have prefix - return
  411. IF ASC(THISPFX$)>58 OR ASC(THISPFX$)<47 THEN THISPFX$=LEFT$(THISENTRY$,4) : GOTO ReturnPfx ' (local portable designator)
  412. K=2 ' find position of first numeral in call
  413. WHILE (ASC(MID$(THISENTRY$,K,1))>57 OR ASC(MID$(THISENTRY$,K,1))<48) AND K<LEN(THISENTRY$)
  414.   K=K+1
  415. WEND
  416. THISPFX$=LEFT$(THISENTRY$,K-1)+THISPFX$ ' new prefix = portable number
  417.                                         ' in old prefix
  418. ReturnPfx:                                        
  419. RETURN
  420. '
  421. '  Subroutine to search prefix library for standard country prefix
  422. '  AND continent
  423. '
  424. SearchPrefix:
  425.  
  426. K=4 : INLIST=NOT TRUE : SAVEDPFX$=THISPFX$
  427. WHILE K>0 AND INLIST=NOT TRUE
  428.   THISPFX$=LEFT$(THISPFX$,K)
  429.   LOW=1 : HIGH=TABLESIZE : INLIST=NOT TRUE ' initial values for
  430.                                            ' binary sort
  431.   WHILE LOW<=HIGH AND INLIST=NOT TRUE
  432.     L=(LOW+HIGH)\2
  433.     IF THISPFX$=PFX$(L) THEN INLIST=TRUE : THISCTRY$=CTRY$(L) : THISCNT$=CNT$(L)
  434.     IF THISPFX$<PFX$(L) THEN HIGH=L-1 ELSE LOW=L+1
  435.   WEND
  436.   K=K-1
  437. WEND
  438. RETURN
  439. '
  440. '  Subroutine to search unusual prefix list 
  441. '
  442. SearchWierd:
  443.  
  444. IF NRWIERDPFX=0 GOTO GetPrefix ' if the supplementary prefix list is
  445.                                ' empty, skip ahead
  446. K=4
  447. WHILE K>0
  448.   SAVEDPFX$=LEFT$(SAVEDPFX$,K)
  449.   FOR J=1 TO NRWIERDPFX
  450.     IF SAVEDPFX$=WIERDPFX$(J) THEN INLIST=TRUE : THISCTRY$=WIERDCTRY$(J) : THISCNT$=WIERDCNT$(J) : J=NRWIERDPFX : K=1
  451.   NEXT J
  452.   K=K-1
  453. WEND
  454. IF INLIST THEN RETURN ' if the prefix was found, return
  455. '
  456. '  Routine to get prefix definition and continent from user for
  457. '  prefix NOT found in LIBRARY
  458. '
  459. GetPrefix:
  460.  
  461. CLS:PRINT CHR$(7) : PRINT
  462. PRINT TAB(5) "The prefix for ";:COLOR 3:PRINT THISENTRY$;
  463. COLOR 1:PRINT " can't be found in the prefix library."
  464. PRINT : PRINT TAB(8) "What is the callsign prefix?  "; 
  465. INPUT "", HELDPFX$:HELDPFX$=UCASE$(HELDPFX$)
  466. PRINT : PRINT TAB(8) "What standard prefix is that equivalent to?  ";
  467. INPUT "", THISPFX$:THISPFX$=UCASE$(THISPFX$)
  468. GOSUB SearchPrefix : IF NOT INLIST GOTO GetPrefix
  469. NRWIERDPFX=NRWIERDPFX+1 : WIERDPFX$(NRWIERDPFX)=HELDPFX$
  470. WIERDCTRY$(NRWIERDPFX)=THISCTRY$ : WIERDCNT$(NRWIERDPFX)=THISCNT$
  471. PRINT
  472. RETURN
  473. '
  474. '  Subroutine to resolve ambiguous prefix with user interaction
  475. '
  476. ResolvePrefix:
  477.  
  478. THISCTRY$=RIGHT$(THISCTRY$,LEN(THISCTRY$)-1) ' strip initial delimiter
  479. J=0
  480. WHILE LEN(THISCTRY$)>0
  481.   J=J+1
  482.   MARK=INSTR(THISCTRY$,".")
  483.   AMBCTRY$(J)=LEFT$(THISCTRY$,MARK-1) ' put multipiler name into array
  484.   THISCTRY$=RIGHT$(THISCTRY$,LEN(THISCTRY$)-MARK)
  485. WEND
  486. CLS : PRINT CHR$(7) : PRINT
  487. PRINT TAB(5) "The prefix for ";:COLOR 3 : PRINT THISENTRY$; 
  488. COLOR 1 : PRINT" could indicate several different countries."
  489. PRINT : PRINT TAB(8) "The possiblities are:" : COLOR 3 : PRINT
  490. FOR K=1 TO J
  491.   PRINT TAB(11) STR$(K); ". "; AMBCTRY$(K) ' print choices to screen
  492. NEXT K
  493. COLOR 1
  494.  
  495. EnterCountry:
  496.  
  497. PRINT : PRINT TAB(8) "Type the number of the correct country. > ";
  498. INPUT "", CHOICE$
  499. K=VAL(CHOICE$) : IF K > J OR K < 1 THEN PRINT CHR$(7); : GOTO EnterCountry
  500. THISCTRY$=AMBCTRY$(K)
  501. CLS : PRINT : PRINT TAB(5) "Back to duping and counting...";
  502. RETURN
  503. '
  504. '  Subroutine to print log sheet header
  505. '
  506. PrintHeader:
  507.  
  508. PRINT #2, "   "; MYCALL$; "  "; BAND$; " MHz Log";  TAB(72); "Page"; STR$(RAWTOTAL\50+1)
  509. PRINT #2, "   Date    Time   Callsign        Sent    Rcvd    New Zone   New Country   Pt."
  510. PRINT #2, " "; STRING$(78,45)
  511. THEDATE$=STR$(DAY)+MON$
  512. RETURN 
  513. '
  514. '  Subroutine to print log sheet footer
  515. '
  516. PrintFooter:
  517.  
  518. IF RAWTOTAL MOD 50=0 GOTO PrintTotals ' if at the end of a page, jump ahead
  519. FOR J=1 TO 50-(RAWTOTAL MOD 50)
  520.   PRINT #2, BL$
  521. NEXT J ' fill last page with blank lines
  522.  
  523. PrintTotals:
  524.  
  525. PRINT #2, " "; STRING$(78,45)
  526. PRINT #2, "    Totals for this page:  Valid QSOs - ";
  527. PRINT #2, USING FOOTFORM$; PGQSOS; PGZONES; PGCTRY; PGPTS
  528. PRINT #2, CHR$(12)
  529. PGQSOS=0 : PGZONES=0 : PGCTRY=0 : PGPTS=0 ' reset page counts
  530. RETURN
  531.